package com.imicode.tel.book.client;

import com.imicode.tel.message.SMSServicePrx;
import com.imicode.tel.message.SMSServicePrxHelper;

public class OnlineBookClient {
	
	public static void main(String[] args) {
		int status = 0;
        Ice.Communicator communicator = null;
        try {
        	String[] initParams = new String[]{"--Ice.Default.Locator=IceGrid/Locator:tcp -h localhost -p 4061"};
            communicator = Ice.Util.initialize(initParams);//初始化
            //ice box
//          Ice.ObjectPrx objectPrx = communicator.stringToProxy("SMSServicek:default -p 10001");
            //ice registry
//          Ice.ObjectPrx objectPrx = communicator.stringToProxy("SMSService@SMSServiceAdapter");
            //ice grid
            Ice.ObjectPrx objectPrx = communicator.stringToProxy("SMSService");
            
            SMSServicePrx smsServicePrx = SMSServicePrxHelper.checkedCast(objectPrx);
            
            if(smsServicePrx == null) {
            	throw new Error("Invalid proxy");
            }

            smsServicePrx.sendSms("bookTick");
        } catch (Exception e) {
            e.printStackTrace();
            status = 1;
        } finally {
            if (communicator != null)
                communicator.destroy();
        }
        System.exit(status);
	}

}
